#!/bin/bash
#kconfig:   2345 90 10
# description:  Redis is a persistent key-value database
NAME=redis-server
RETAVL=0
#检查shelk公共函数库是否存在，存在就加载
FUNCTIONS_PATH=/etc/init.d/functions
[ -f $FUNCTIONS_PATH ]&& source $FUNCTIONS_PATH
#检查redis文件是否存在并可执行
[ -x $REDIS_SERVER ]|| exit 0

#检查是否执行成功
check(){
	RETAVL=$?
	if
		[ $RETAVL -eq 0 ];then
		action "redis is $1" /bin/true
	else
		action "redis is $1" /bin/false
	fi
}

#停止服务
stop(){
  ID=`ps -ef | grep "redis" | grep -v "grep" | awk '{print $2}'`
  if [ ! -z "$ID" ];then
      for id in $ID
      do
        kill -9 $id
        check stopped
      done
  else
      action "redis is stop" /bin/true
  fi
}

echo "-----函数开始执行-----"
stop
echo "-----函数执行完毕-----"
